/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MNetSockets.CmdChanel;

import java.util.logging.Level;
import java.util.logging.Logger;

/**
 *
 * @author wcss
 */
public class CmdRun implements Runnable {

    public IDataReader reader = null;
    public CmdClient client = null;

    public CmdRun(IDataReader dr,CmdClient cc) {
        this.reader = dr;
        this.client = cc;
    }
    
    public void handleDataRead(Object data) {
        if (reader != null) {
            this.reader.dataRead(this.client, data);
        }
    }

    @Override
    public void run() {
//        StringBuilder sb = new StringBuilder();
//        String content = null;
//        int flagindex = 0;
//        while (this.client.getConnected()) {
//            if (this.client.queue.size() > 0) {
//                sb.append(this.client.queue.poll());
//            }
//
//            flagindex = sb.indexOf("###");
//            if (flagindex > 0) 
//            {
//                content = sb.substring(0,flagindex + 3);
//                sb.delete(0, flagindex + 3);
//                this.handleDataRead(content);                
//            }
//
//            try {
//                Thread.sleep(50);
//            } catch (InterruptedException ex) {
//                Logger.getLogger(CmdRun.class.getName()).log(Level.SEVERE, null, ex);
//            }
//        }
    }
}
